package com.boot.security.model.bo;

import com.boot.security.model.dto.LoginAccount;
import com.boot.security.model.vo.WebDetail;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description 登录时所用的验证消息
 * @date 2020/2/15 18:21
 **/

public class LoginAccountAuthentication implements Authentication {

    private final LoginAccount loginAccount;

    private final WebDetail detail;

    public LoginAccountAuthentication(LoginAccount loginAccount, WebDetail detail) {
        this.loginAccount = loginAccount;
        this.detail = detail;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public Object getCredentials() {
        return loginAccount.getCredential();
    }

    @Override
    public WebDetail getDetails() {
        return detail;
    }

    @Override
    public Object getPrincipal() {
        return loginAccount.getPrincipal();
    }

    @Override
    public boolean isAuthenticated() {
        return false;
    }

    @Override
    public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {

    }

    @Override
    public String getName() {
        return loginAccount.getPrincipal();
    }

    public LoginAccount getLoginAccount() {
        return loginAccount;
    }

}
